package com.drs.challenge.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.drs.challenge.bean.Audio;
import com.drs.challenge.service.AudioService;
import com.drs.challenge.mapper.AudioMapper;
import org.springframework.stereotype.Service;

/**
 *
 * @description 针对表【audio(音频)】的数据库操作Service实现
 * @Date 2023-07-06 09:08:26
 * @author Jasmine-drs
 */
@Service
public class AudioServiceImpl extends ServiceImpl<AudioMapper, Audio> implements AudioService{

	private final AudioMapper audioMapper;

	public AudioServiceImpl(AudioMapper audioMapper) {
		this.audioMapper = audioMapper;
	}

	@Override
	public void saveAudio(byte[] bytes, String uuid) {
		Audio audio = new Audio();
		audio.setId(uuid);
		audio.setAudio(bytes);
		audio.setStatus(1);
		audioMapper.updateById(audio);
	}

	@Override
	public Audio getAudio(String uuid) {
		Audio audio = audioMapper.selectById(uuid);
		return audio;
	}

	@Override
	public void saveAudioInQRCode(byte[] qrCode, String id) {
		Audio audio = new Audio();
		audio.setId(id);
		audio.setQr(qrCode);
		audioMapper.insert(audio);
	}
}




